const mongoose = require('mongoose')
const baseModel = require('./base-model')
const Schema = mongoose.Schema;
// 为集合（表）创建模式（schema)
const userSchema = Schema({
    ...baseModel,
    username: {
        unique:true,
        type:String,
        required:true,
        trim:true
    },
    password: {
        type:String,
        required:true,
        // 返回数据的时候设置不要把password返回回去（仅适用于查询数据，创建数据时使用delete将相关属性删除）
        select:false,
        trim:true
    },
    nickname: {
        type:String,
        required:true,
        trim:true
    },
    email: {
        type:String,
        required:true,
        trim:true
    },
    avatar: {
        type:String,
        default:""
    },
    sex: {
        type:String,
        required:true
    },
    isEnable: {
        type:Boolean,
        default:true
    }
});
userSchema.set('toJSON', { getters: true });
module.exports = userSchema